package com.ming.attendance.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 声明拦截器对象
        HandlerInterceptor interceptor = new TokenCheckInterceptor();
        registry.addInterceptor(interceptor)
                // 将所有请求都进行拦截
                .addPathPatterns("/**")
                // 排除登录请求的拦截
                .excludePathPatterns("/WxUser/login");

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
